/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ticketmachine.logic;

import java.util.Date;


/**
 *
 * @author oiiv2253
 */
public class Ticket {

    private Date purchaseDate;
    private Station destination;
    private Station source;
    private float price;
    private float taxes;
    private TicketDescription description;
    private Promotion promotion;

    public class TicketDetails{
    	String source;
    	String destination;
    	String price;
    	String taxes;
    	String promocion;
    	String type;
    	
    	public TicketDetails(String source, String destination, String price,
				String taxes, String promocion, String type) {
			super();
			this.source = source;
			this.destination = destination;
			this.price = price;
			this.taxes = taxes;
			this.promocion = promocion;
			this.type = type;
		}

		public String getSource() {
			return source;
		}

		public String getDestination() {
			return destination;
		}

		public String getPrice() {
			return price;
		}

		public String getPromocion() {
			return promocion;
		}

		public String getType() {
			return type;
		}

		public String getTaxes() {
			return taxes;
		}

		public void setTaxes(String taxes) {
			this.taxes = taxes;
		}

                public String getPriceWithTaxes() {

                    float price = Float.valueOf(this.price);
                    float taxes = Float.valueOf(this.taxes);

                    return String.valueOf(taxes+price);
                }
		
    }
    
    //For reason it feels that these can be added straight awat when the ticket is created
    public Ticket(TicketDescription ticketType, Station source) {

        this.setDescription(ticketType);
        this.setSource(source);
    }

    public TicketDescription getDescription() {
        return description;
    }

    public void setDescription(TicketDescription description) {
        this.description = description;
        //System.out.println("Ticket type is: " + description.getName());
    }

    public Station getDestination() {
        return destination;

    }

    public void setDestination(Station destination) {
        this.destination = destination;
        //System.out.println("Ticket destination is: " + destination.name);
    }

    public Promotion getPromotion() {
        return promotion;
    }

    public void setPromotion(Promotion promotion) {
        this.promotion = promotion;
        //System.out.println("Ticket promotion is: " + promotion.name);
    }

    public Date getPurchaseDate() {
        return purchaseDate;
    }

    public void setPurchaseDate(Date purchaseDate) {
        this.purchaseDate = purchaseDate;
    }

    public Station getSource() {
        return source;
    }

    public void setSource(Station source) {
        this.source = source;
        //System.out.println("Ticket source is: " + source.name);
    }

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}
	
	public float getTaxes() {
		return taxes;
	}

	public void setTaxes(float taxes) {
		this.taxes = taxes;
	}

	public TicketDetails getTicketDetails(){
		String promo=getPromotion()==null?"none":getPromotion().getName();
                String source =getSource()==null?"none":getSource().getName();
                String dest =getDestination()==null?"none":getDestination().getName();
		return new TicketDetails(source,dest,price+"",taxes+"",promo,description.getName());
	}
    


}
